package com.AO.struts;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.AO.DAO.*;

public class Action {
	public String execute()throws Exception
	{
		HttpServletRequest request=ServletActionContext.getRequest();
		HttpSession session=request.getSession();

			StringBuffer str=request.getRequestURL();
			String url=str.toString().substring(str.indexOf("AO")+2,str.length()-7);
            if(url.startsWith("Food."))
            {
            	request.setAttribute("Foodid", url.substring(url.indexOf(".")+1));
            	return "Food";
            }
            if(url.startsWith("Mfood."))
            {
            	request.setAttribute("MFoodid", url.substring(url.indexOf(".")+1));
            	return "Mfood";
            }
            if(url.startsWith("HomePage."))
            {
            	return "HomePage";
            }
            if(url.startsWith("Menu."))
            {
            	return "Menu";
            }
            if(url.startsWith("MfoodMenu."))
            {
            	request.setAttribute("MFoodTypeid", url.substring(url.indexOf(".")+1));
            	return "MfoodMenu";
            }
            if(url.startsWith("FoodMenu."))
            {
            	request.setAttribute("FoodTypeid", url.substring(url.indexOf(".")+1));
            	return "FoodMenu";
            }
			if(url.startsWith("Cooker."))
            {
            	request.setAttribute("CookerAccount",url.substring(url.indexOf(".")+1));
            	return "Cooker";
            }
			if(url.startsWith("FoodInMenu."))
            {
            	request.setAttribute("FoodInMenuId",url.substring(url.indexOf(".")+1));
            	return "FoodInMenu";
            }
			if(url.startsWith("FoodInMenuList."))
            {
            	return "FoodInMenuList";
            }
			if(url.startsWith("FoodList."))
            {
            	return "FoodList";
            }
			if(url.startsWith("CookerList."))
            {
            	return "CookerList";
            }
            else
            {
            	return "WrongPage";
            }
	}
}
